package com.bauer.java.spring.aop.traditional;

import org.springframework.aop.framework.ProxyFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class AopMain {
    public static void main(String[] args) {
        ProxyFactory proxyFactoryBean =  new ProxyFactory();

        proxyFactoryBean.setTarget(new HaDog());
        proxyFactoryBean.addAdvice(new MyBeforeAdvice());
        proxyFactoryBean.addAdvice(new MyAfterAdvice());

        Dog dog = (Dog) proxyFactoryBean.getProxy();
        dog.hashCode();

        ApplicationContext ctx=new ClassPathXmlApplicationContext("spring/aop.xml");
        Dog dog1 = (Dog)ctx.getBean("math");
        dog1.wang();
    }
}
